package com.yidu.ladder.base.controller;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.ladder.base.domain.Time;
import com.yidu.ladder.base.domain.TimeVo;
import com.yidu.ladder.base.service.TimeService;
import com.yidu.ladder.util.ID;


@Controller
@RequestMapping("/base/")
public class TimeController {

	@Autowired
	private TimeService timeService;

	public TimeController(TimeService timeService) {
		super();
		this.timeService = timeService;
	}

	public TimeController() {
		super();
	}

	public TimeService getTimeService() {
		return timeService;
	}

	public void setTimeService(TimeService timeService) {
		this.timeService = timeService;
	}
	
	/**
	 * 检索
	 * 
	 * @param userVo 包装类
	 * @return 信息数据
	 */
	@ResponseBody
	@RequestMapping(value = "times")
	public Map<String, Object> queryUser(TimeVo timeVo) {
		Map<String, Object> userMap = timeService.pageQuerytime(timeVo);
		return userMap;
	}
	
	/*
	 * *** 删除
	 * 
	 * @param Staff
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="time/{timeId}/{useable}",method=RequestMethod.DELETE)
	public String frozenORrecoverArchives(@PathVariable("timeId") String timeIdstr, @PathVariable("useable") String useable) {
		boolean result = timeService.updatefreeze(timeIdstr, useable);
		if(result==false) {
			return "fail";
		}
		return "success";
	}
	
	/**
	 * 添加数据
	 * 
	 * @param archives
	 * @re9turn
	 */
	@ResponseBody
	@RequestMapping(value = "addtime", method = RequestMethod.POST)
	public int addtime(Time time) {
		    time.setTimeId(ID.getUUID());
			int dd = timeService.addtime(time);
			return dd;
		 } 
	/***
	 * 修改数据
	 * 
	 * @param archives
	 * @return
	 */
	@RequestMapping(value = "updatetime", method = RequestMethod.POST)
	@ResponseBody
	public int updateStaff(Time time) {
			int dd = timeService.updatepicture(time);
			return dd;
		 } 
}
